function e(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

var a = e(require("../../api/api.js")), t = (e(require("../../utils/util.js")), 
e(require("../../utils/filter.js")), require("../../config/constants.js")), r = e(require("../../devops/raven/raven")), s = getApp();

Page({
    data: {
        userPersonalInfo: {},
        hasUserInfo: !1
    },
    loadPage: function() {
        0 !== Object.keys(s.globalData.userPersonalInfo).length && wx.switchTab({
            url: "../teacher/teacher"
        });
    },
    bindGetUserInfo: function(e) {
        var n = this;
        wx.login({
            success: function(e) {
                var o = e.code;
                e.code && wx.getUserInfo({
                    success: function(e) {
                        var u = e, i = {
                            code: o,
                            wechatUserDict: JSON.stringify(u)
                        };
                        a.default.loginViaWechat({
                            method: "POST",
                            data: i,
                            success: function(e) {
                                if (e && e.data.data) {
                                    var a = e.data.data;
                                    if (a.unionid) wx.setStorage({
                                        key: "userInfo",
                                        data: a
                                    }), wx.switchTab({
                                        url: "../user/user"
                                    }); else {
                                        var o = e.header["x-token"] || e.header["X-Token"], u = e.header["v-token"] || e.header["V-Token"], i = e.data.data;
                                        i.user_avatar_file = t.CDN_ADDR + i.avatar_file_name + "_Avatar.jpg", s.globalData.userPersonalInfo = i, 
                                        s.globalData.token = o, s.globalData.vtoken = u, wx.setStorage({
                                            key: "userPersonalInfo",
                                            data: i
                                        }), wx.setStorage({
                                            key: "token",
                                            data: o
                                        }), wx.setStorage({
                                            key: "vtoken",
                                            data: u
                                        }), n.loadPage(), r.default.setUserContext(a);
                                    }
                                }
                            }
                        });
                    }
                });
            }
        });
    },
    switchTab: function(e) {
        this.setData({
            currentNavtab: e.currentTarget.dataset.idx
        });
    },
    bindViaAccount: function() {
        wx.switchTab({
            url: "../user/user"
        });
    },
    onLoad: function() {
        var e = this;
        e.loadPage(), wx.getStorage({
            key: "userPersonalInfo",
            success: function(a) {
                e.setData({
                    userPersonalInfo: a.data,
                    hasUserInfo: !0
                });
            }
        });
    }
});